package com.gz.servlet_my;

import com.gz.tomcat.http.GzRequest;
import com.gz.tomcat.http.GzResponse;
import com.gz.utils.WebUtils;

import java.io.IOException;
import java.io.OutputStream;

public class GzCalServlet2 extends GzHttpServlet{

    @Override
    public void doGet(GzRequest request, GzResponse response) throws IOException {
        int num1= WebUtils.parseInt(request.getParameter("num1"),0);
        int num2= WebUtils.parseInt(request.getParameter("num2"),0);
        int sum= num1*num2;
        OutputStream outputStream = response.getOutputStream();
        String respHeader = response.getRespHeader();
        String resMessage=respHeader+"<h1> num1*num2="+num1+"*"+num2+"="+sum+"</h1>";
        outputStream.write(resMessage.getBytes());
        outputStream.flush();
        outputStream.close();
    }

    @Override
    public void doPost(GzRequest request, GzResponse response) throws IOException {
        doGet(request, response);
    }

}
